/*
* pps-cloud
*/
package com.pitop.succedaneum.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.succedaneum.api.SuccedaneumMaterialFeignApi;
import com.pitop.core.exceptions.SuccedaneumMaterialException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.succedaneum.entity.SuccedaneumMaterial;


/**
 * 可替代料材
 * @author berton
 */
@Service("succedaneumMaterialSVImpl")
@Slf4j
public class SuccedaneumMaterialSVImpl {

    @Autowired
    private SuccedaneumMaterialFeignApi succedaneumMaterialFeignApi;

    /**
     * 加载一个对象SuccedaneumMaterial
     * @param id id* @param code 编码
     * @return SuccedaneumMaterial
     */
    public SuccedaneumMaterial load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return succedaneumMaterialFeignApi.load(id,code);
    }
    /**
     * 加载一个对象SuccedaneumMaterial 通过id
     * @param id id
     * @return SuccedaneumMaterial
     */
    public SuccedaneumMaterial loadById(java.lang.Long id) {
        if(id==null){
            throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return succedaneumMaterialFeignApi.loadById(id);
    }

    /**
     * 加载一个对象SuccedaneumMaterial 通过code
     * @param code 编码
     * @return SuccedaneumMaterial
     */
    public SuccedaneumMaterial loadByCode(java.lang.String code) {
        if(code==null){
            throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return succedaneumMaterialFeignApi.loadByCode(code);
    }


    /**
     * 删除对象SuccedaneumMaterial
     * @param id id* @param code 编码
     * @return SuccedaneumMaterial
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        succedaneumMaterialFeignApi.delete(id,code);
    }



    /**
     * 查询SuccedaneumMaterial分页
     *
     * @param succedaneumMaterial  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<SuccedaneumMaterial>
     */
    public List<SuccedaneumMaterial> list(SuccedaneumMaterial succedaneumMaterial, int curPage,int pageSize) {
        return succedaneumMaterialFeignApi.list(succedaneumMaterial, curPage,pageSize);
    }

    /**
     * 查询SuccedaneumMaterial分页
     *
     * @param id  id* @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<SuccedaneumMaterial>
     */
    public List<SuccedaneumMaterial> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        SuccedaneumMaterial succedaneumMaterial=new SuccedaneumMaterial();
        succedaneumMaterial.setId(id);
        succedaneumMaterial.setCode(code);

        return succedaneumMaterialFeignApi.list(succedaneumMaterial,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return succedaneumMaterialFeignApi.count(id,code);
    }


    public int count(SuccedaneumMaterial succedaneumMaterial) {
        return succedaneumMaterialFeignApi.count(succedaneumMaterial);
    }


    /**
     * 保存
     *
     * @param succedaneumMaterial 实体
     * @throws BaseException
     */
    public void save(SuccedaneumMaterial succedaneumMaterial) {
        if(succedaneumMaterial==null){ throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        succedaneumMaterialFeignApi.build(succedaneumMaterial);
    }

    /**
     * 更新
     *
     * @param succedaneumMaterial 实体
     * @throws BaseException
     */
    public void modify(SuccedaneumMaterial succedaneumMaterial) {
        if(succedaneumMaterial==null){ throw new SuccedaneumMaterialException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        succedaneumMaterialFeignApi.modify(succedaneumMaterial);
    }

}
